from flask import Flask,make_response,request,jsonify,session

app=Flask(__name__)
app.secret_key="low game"
@app.route('/')
def init_hero():
    ret=make_response("刺激角色成功")
    ret.set_cookie("ack")
    ret.set_cookie("hp","10")
    return ret
@app.route('/layer/1')
def layer_1():
    session["layer"]="2"
    return {"msg":"""遇见一条蛇。
    A:攻击
    B:捕捉
    C：红烧"""}

@app.route('/layer/2')
def layer_2():
    if session.get("layer") !="2":
        return "下一关"
    ret=make_response("asdf")
    q=request.args.get("q")
    if q.lower()=="a":
        msg="已经杀，掉落蛇胆，吃了持续增加50血（20秒）"
        ret.set_cookie('hp',str(int(request.cookies.get('hp'))+20))
    elif q.lower()=="b":
        ...
    elif q.lower()=="c":
        ...
    print(ret.data)
    ret.data=bytes('{"msg":msg,"new layer":"""碰见老虎'
    'A：攻击'
    'B：捕捉'
    'C：等死"""}'.encode("utf-8"))
    session["layer"]="3"
    return ret
@app.route('/layer/3')
def layer_3():
    if session.get("layer") !="3":
        return "下一关"
    ret=make_response("asdf")
    q=request.args.get("q")
    if q.lower()=="a":
        msg="已经杀，掉落虎皮衣，增加150血"
        ret.set_cookie('hp',str(int(request.cookies.get('hp'))+20))
    elif q.lower()=="b":
        ...
    elif q.lower()=="c":
        ...
    print(ret.data)
    ret.data=bytes('{"msg":msg,"new layer":"""碰见猴子'
    'A：攻击'
    'B：捕捉'
    'C：等死"""}'.encode("utf-8"))
    session["layer"]="4"
    return ret
@app.route('/layer/4')
def layer_4():
    if session.get("layer") !="4":
        return "下一关"
    ret=make_response("asdf")
    q=request.args.get("q")
    if q.lower()=="a":
        msg="已经杀，掉落猴子手套，增加150攻击"
        ret.set_cookie('hp',str(int(request.cookies.get('hp'))+20))
    elif q.lower()=="b":
        ...
    elif q.lower()=="c":
        ...
    print(ret.data)
    ret.data=bytes('{"msg":msg,"new layer":"""碰见猪'
    'A：攻击'
    'B：捕捉'
    'C：等死"""}'.encode("utf-8"))
    session["layer"]="5"
    return ret
@app.route('/layer/5')
def layer_5():
    if session.get("layer") !="4":
        return "下一关"
    ret=make_response("asdf")
    q=request.args.get("q")
    if q.lower()=="a":
        msg="已经杀，掉落猪帽，增加150血"
        ret.set_cookie('hp',str(int(request.cookies.get('hp'))+20))
    elif q.lower()=="b":
        ...
    elif q.lower()=="c":
        ...
    print(ret.data)
    ret.data=bytes('{"msg":msg,"new layer":"""碰见鸟'
    'A：攻击'
    'B：捕捉'
    'C：等死"""}'.encode("utf-8"))
    session["layer"]="6"
    return ret

if __name__=="__main__":
    app.run()